﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using WMM.Tapioca.Linkbase;

namespace WMM.Tapioca.Formula
{
    /// <summary>
    /// Validation messages allow associating messages to an assertion, to compose text 
    /// (or structured XML) for successful or not-successful evaluations.
    /// </summary>
    public class Message : FormulaResource
    {        
        private string lang;

        /// <returns> lang of message. </returns>
        public string Lang
        {
            get { return lang; }
            set { lang = value; }
        }

        private string content;

        /// <returns> Content of message. </returns>
        public string Content
        {
            get { return content; }
            set { content = value; }
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        public Message(Resource resource) : base(resource)
        {            
            content = resource.ResourceXElement.Value;

            foreach (XAttribute attr in resource.ResourceXElement.Attributes())
            {
                if (attr.Name.LocalName.Equals("lang"))
                {
                    lang = attr.Value;
                }
            }
        }
    }
}
